

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/Mine.jpg">
  <link rel="icon" href="/img/Mine.jpg">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Chiam">
  <meta name="keywords" content="算法，安全">
  
    <meta name="description" content="『算法-ACM 竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)一、无重复元素的排列组合定义 排列，英文名为 Permutation，是指从某元素集合中取出指定个数的元素进行排序组合，英文名为 Combination，是指从某元素集合中仅仅取出指定个数的元素，不考虑排序 从有 n 个不同元素的集合任取 r 个元素的排列方式有：$P(n, r) &#x3D; n*(n-1)…(n-r+">
<meta property="og:type" content="article">
<meta property="og:title" content="『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)">
<meta property="og:url" content="http://example.com/2023/12/06/%E3%80%8E%E7%AE%97%E6%B3%95-ACM%E7%AB%9E%E8%B5%9B-%E6%95%B0%E5%AD%A6-%E6%95%B0%E8%AE%BA%E3%80%8F%20%E7%BB%84%E5%90%88%E6%95%B0+%E5%8D%A2%E5%8D%A1%E6%96%AF%E5%AE%9A%E7%90%86+%E6%89%A9%E5%B1%95%E5%8D%A2%E5%8D%A1%E6%96%AF%E5%AE%9A%E7%90%86%20(2)/index.html">
<meta property="og:site_name" content="Chiam 的个人主页">
<meta property="og:description" content="『算法-ACM 竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)一、无重复元素的排列组合定义 排列，英文名为 Permutation，是指从某元素集合中取出指定个数的元素进行排序组合，英文名为 Combination，是指从某元素集合中仅仅取出指定个数的元素，不考虑排序 从有 n 个不同元素的集合任取 r 个元素的排列方式有：$P(n, r) &#x3D; n*(n-1)…(n-r+">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20191212212757710.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20191212212810639.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzYyNzExOA==,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/2019121221281816.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzYyNzExOA==,size_16,color_FFFFFF,t_70">
<meta property="article:published_time" content="2023-12-05T16:11:44.736Z">
<meta property="article:modified_time" content="2023-12-05T16:19:29.534Z">
<meta property="article:author" content="Chiam">
<meta property="article:tag" content="算法，安全">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/20191212212757710.png">
  
  
  
  <title>『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2) - Chiam 的个人主页</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="/css/custom.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":"❡"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":2},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Chiam&#39;s Blogs</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                
                <span>关于</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/links/">
                
                <span>友链</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-12-06 00:11" pubdate>
          2023年12月6日 凌晨
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          2.9k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          25 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="『算法-ACM-竞赛-数学-数论』-组合数-卢卡斯定理-扩展卢卡斯定理-2"><a href="#『算法-ACM-竞赛-数学-数论』-组合数-卢卡斯定理-扩展卢卡斯定理-2" class="headerlink" title="『算法-ACM 竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)"></a>『算法-ACM 竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)</h1><p><strong>一、无重复元素的排列组合定义</strong></p>
<p>排列，英文名为 Permutation，是指从某元素集合中取出指定个数的元素进行排序<br>组合，英文名为 Combination，是指从某元素集合中仅仅取出指定个数的元素，不考虑排序</p>
<p>从有 n 个不同元素的集合任取 r 个元素的排列方式有：<br>$P(n, r) &#x3D; n*(n-1)<em>…</em>(n-r+1) &#x3D; n! &#x2F; (n-r)!,特别地 P(n,n) &#x3D; n!$</p>
<p>从有 n 个不同元素的集合任取 r 个元素的组合方式有：<br>$C(n, r) &#x3D; P(n, r) &#x2F; r! &#x3D; n! &#x2F; ( (n-r)! * r!)，特别地C(n,n) &#x3D; 1$</p>
<p><strong>二、多重集合（multiset）的排列组合</strong></p>
<p>设多重集合 $S &#x3D; { n1 * a1, n2 * a2, …, nk * ak }\ \ \ \ \ n &#x3D; n1 + n2 + … + nk$</p>
<p>即集合 S 中含有 n1 个元素 a1， n2 个元素 a2，…，nk 个元素 ak，ni 被称为元素 ai 的重数，k 成为多重集合的类别数</p>
<p>在 S 中任选 r 个元素的排列称为 S 的 r 排列，当 r &#x3D; n 时，有公式<br>$P(n; n1<em>a1, n2</em>a2, …, nk<em>ak) &#x3D; n! &#x2F; (n1! * n2! * …</em> nk!)$</p>
<p>在 S 中任选 r 个元素的组合称为 S 的 r 组合，当 r&lt;&#x3D;任意 ni 时，有公式<br>$C(n; n1<em>a1, n2</em>a2, …, nk*ak) &#x3D; C(k+r-1, r)$</p>
<p>由公式可以看出多重集合的组合只与类别数 k 和选取的元素 r 有关，与总数无关！</p>
<p><strong>三、多重集合问题的转化例子</strong></p>
<p><strong>例 1：线性方程 x1 + x2 + … + xk &#x3D; r 一共有多少组非负整数解？</strong></p>
<p>解答：上述不定方程的非负整数解对应于下述排列</p>
<p>1…101…1 01…1 0 …… 01…1</p>
<p>x1 个 x2 个 x3 个 …… xk 个</p>
<p>其中 k-1 个 0 将 r 个 1 分成 k 段， 每段含 1 的个数分别为 x1, x2, …, xk,</p>
<p>很明显这个排列是多重集合 S &#x3D; { r _ 1， （k-1）_ 0 }的全排列</p>
<p>即：P(r+k-1; r*1, (k-1)*0) &#x3D; (r+k-1)! &#x2F; ( r! * (k-1)! ) &#x3D; C( r+k-1, r),即从 k 类元素中选 r 个的种类</p>
<p><strong>例二：某车站有 6 个入口处，每个入口处每次只能进一个人， 一组 9 个人进站的方案有多少？</strong></p>
<p>解答：进站方案可以表示为</p>
<p>1 011 011 01 011 01</p>
<p>g1 g2 g3 g4 g5 g6</p>
<p>其中 1 表示不同的人， 而 0 表示门框, 6-1&#x3D; 5 个门框将序列分为六段,</p>
<p>则任意进站方案可表示成上面 14 个元素 S &#x3D; { 5 _ 1, 1 _ p1, 1 _ p2, …, 1 _ p9 }的一个排列</p>
<p>即：P(5+9;5<em>1, 1</em>p1, 1<em>p2, …, 1</em>p9) &#x3D; 14! &#x2F; ( 5! _ 1! _ …. 1! ) &#x3D; 14! &#x2F; 5!</p>
<p><strong>例三、求从（0,0）点到（m,n）点的非降路径数</strong></p>
<p>解答：无论哪条路径，必须在 x 方向上走 m 步，y 方向上走 n 步，将非降路径数与多重集合 S &#x3D; { m _ x, n _ y } 的排列建立一一对应关系，所以格路总数为 P(m+n; m<em>x, n</em>y) &#x3D; (m+n)! &#x2F; ( m! * n! ) &#x3D; C(m+n, n) &#x3D; C(m+n, m)</p>
<p>一般地，设 c&gt;&#x3D;a, d&gt;&#x3D;b,则由(a,b)到(c,d)的非降路径数为 C(c-a+d-b, c-a)</p>
<p>扩展问题： 在上例基础上若设 m&lt;n,求点（0,1）到点(m,n)不接触对角线 y&#x3D;x 的非降路径数据（接触包括穿过）</p>
<p>解答：从（0,1）到(m,n)的非降路径，有的接触 y&#x3D;x，有的不接触，对于每条接触 y&#x3D;x 的非降路径，做(0,1)关于 y&#x3D;x 的对称点(1,0)到(m,n)的对称非降路径，容易看出从（0,1）到（m,n）接触 y&#x3D;x 的非降路径与 （1,0）到(m,n)的非降路径（必穿过 y&#x3D;x）一一对应，</p>
<p>故所求的非降路径数为 C(m+n-1, m) - C(m+n-1, m-1)</p>
<p><strong>例四、将 r 个相同的小球放入 n 个不同的盒子，总共有多少种方案？</strong></p>
<p>解答：该问题可以转化为 r 个相同的小球与 n-1 个相同的盒壁的排列问题</p>
<p>1…1 0 1…1 0 1…1 0 …… 0 1…1</p>
<p>其中有 n-1 个 0 分成 n 段,每段表示不同的盒子， 每段中 1 的个数表示该盒子里放入的小球总数，总共 r 个 1</p>
<p>即：P( r+n-1; r*1, (n-1)*0 ) &#x3D; (r+n-1)! &#x2F; ( r! * (n-1)! ) &#x3D; C( r+n-1, r)</p>
<p><strong>例五、求集合 X &#x3D; { 1,2，…, n }的不含相邻整数的 k 元子集个数</strong></p>
<p>解答：任意一个 X 的 k 元子集 s 都可以对应于一个由 0,1 组成的有序 n 重组（a1 a2 … an）,其中 ai &#x3D; 1 当 i 属于 s，否则 ai &#x3D; 0，当 i 不属于 s，由于 s 中不含相邻整数，所以在此 n 重组中没有两个 1 是相邻的，所以子集 s 是与这样的 n 重组 S &#x3D; { k*1, (n-k)*0 }之间是一一对应的，由于任意两个 1 彼此不相邻，故可以把（n-k）个 0 依次排列，然后在（n-k+1）个空隙中插入 k 个 1，所以从（n-k+1）个空隙中选择 k 个位置来放置 1，有 C(n-k+1, k) 种选法，这也是原问题所对应的答案。</p>
<p><strong>四、母函数</strong><br>生成函数（母函数）有普通生成函数和指数生成函数： 1.普通生成函数用于解决多重集的组合问题</p>
<p>2.指数型母函数用于解决多重集的排列问题</p>
<p>母函数可以解决递归数列的通项问题：斐波那契数列、卡特兰数列等</p>
<p><strong>普通母函数：</strong><br>构造母函数 G(x), G(x) &#x3D; a0 + a1<em>x + a2</em> + a3* +….+ an*， 则称 G(x)是数列 a0,a1…an 的母函数。</p>
<p>通常普通母函数用来解多重集的组合问题，其思想就是构造一个函数来解决问题，一般过程如下：</p>
<p><strong>1.建立模型：</strong></p>
<p>物品 n 种,每种数量分别为 k1,k2,..kn 个，每种物品又有一个属性值 p1,p2,…pn,(如本题的字母价值)，求属性值和为 m 的物品组合方法数。（若数量 ki 无穷 也成立，即对应下面式子中第 ki 项的指数一直到无穷）</p>
<p><strong>2.构造母函数：</strong></p>
<p>G(x)&#x3D;(1++…)(1+++…)…(1+++…) （一）</p>
<p>&#x3D;a0 + a1<em>x + a2</em> + a3* +….+ akk* (设 kk&#x3D;k1·p1+k2·p2+…kn·pn) （二）</p>
<p>G(x)含义： ak 为属性值和为 k 的组合方法数。</p>
<p>母函数利用的思想： 1.把组合问题的加法法则和幂级数的乘幂对应起来。</p>
<p>2.把离散数列和幂级数对应起来，把离散数列间的相互结合关系对应成为幂级数间的运算关系，最后由幂级数形式来 确定离散数列的构造。</p>
<p><strong>代码实现：</strong><br>求 G(x)时一项一项累乘。先令 G&#x3D;1&#x3D;(1+0<em>x+0</em>+…0*),再令 G&#x3D;G*(1++…)得到形式(二)的式子…最后令 G&#x3D;G*(1+++…)。<br>下面是指数型母函数的定义：</p>
<p><img src="https://img-blog.csdnimg.cn/20191212212757710.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/20191212212810639.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzYyNzExOA==,size_16,color_FFFFFF,t_70" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p>对于上面的问题“假设有 8 个元素，其中 a1 重复 3 次，a2 重复 2 次，a3 重复 3 次。从中取 r 个组合，求其组合数。”：</p>
<p>（感谢 3Dnn 同学指出，下图的 28&#x2F;3! 应该改为 26&#x2F;3!）<br><img src="https://img-blog.csdnimg.cn/2019121221281816.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzYyNzExOA==,size_16,color_FFFFFF,t_70" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<blockquote>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_40507857/article/details/82824047">引用博客 1</a><br><a target="_blank" rel="noopener" href="http://www.wutianqi.com/blog/2644.html">引用博客 2</a> &gt; <a target="_blank" rel="noopener" href="https://blog.csdn.net/kennyrose/article/details/7469528">引用博客 3</a></p>
</blockquote>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E7%AE%97%E6%B3%95/" class="category-chain-item">算法</a>
  
  
    <span>></span>
    
  <a href="/categories/%E7%AE%97%E6%B3%95/ACM%E7%AB%9E%E8%B5%9B/" class="category-chain-item">ACM竞赛</a>
  
  
    <span>></span>
    
  <a href="/categories/%E7%AE%97%E6%B3%95/ACM%E7%AB%9E%E8%B5%9B/%E6%95%B0%E5%AD%A6/" class="category-chain-item">数学</a>
  
  
    <span>></span>
    
  <a href="/categories/%E7%AE%97%E6%B3%95/ACM%E7%AB%9E%E8%B5%9B/%E6%95%B0%E5%AD%A6/%E6%95%B0%E8%AE%BA/" class="category-chain-item">数论</a>
  
  

  

  

  

      </span>
    
  
</span>

    </div>
  
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)</div>
      <div>http://example.com/2023/12/06/『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (2)/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Chiam</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年12月6日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2023/12/06/%E3%80%8E%E7%AE%97%E6%B3%95-ACM%E7%AB%9E%E8%B5%9B-%E6%95%B0%E5%AD%A6-%E6%95%B0%E8%AE%BA%E3%80%8F%20%E7%BB%84%E5%90%88%E6%95%B0+%E5%8D%A2%E5%8D%A1%E6%96%AF%E5%AE%9A%E7%90%86+%E6%89%A9%E5%B1%95%E5%8D%A2%E5%8D%A1%E6%96%AF%E5%AE%9A%E7%90%86%20(3)/" title="『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (3)">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (3)</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2023/12/06/%E3%80%8E%E7%AE%97%E6%B3%95-ACM%E7%AB%9E%E8%B5%9B-%E6%95%B0%E5%AD%A6-%E6%95%B0%E8%AE%BA%E3%80%8F%20%E7%BB%84%E5%90%88%E6%95%B0+%E5%8D%A2%E5%8D%A1%E6%96%AF%E5%AE%9A%E7%90%86+%E6%89%A9%E5%B1%95%E5%8D%A2%E5%8D%A1%E6%96%AF%E5%AE%9A%E7%90%86%20(1)/" title="『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (1)">
                        <span class="hidden-mobile">『算法-ACM竞赛-数学-数论』 组合数+卢卡斯定理+扩展卢卡斯定理 (1)</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"fIfc7WqUDZohlQuPc2lz5mJy-MdYXbMMI","appKey":"zjlAG3ZA3o4cBHVAkjzc2Z20","path":"window.location.pathname","placeholder":"留言仅限讨论，禁止广告等行为","avatar":"retro","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":false,"recordIP":false,"serverURLs":"https://fifc7wqu.api.lncldglobal.com","emojiCDN":null,"emojiMaps":null,"enableQQ":false},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <meta name="referrer" content="no-referrer" /> <footer id="footer" role="contentinfo"> <div class="divider"> <div class="wall"></div> <img class="animals" src="/img/footer_animals_new.png" srcset="/img/loading.gif" lazyload alt="Footer Animals"> </div> <div class="container" data-index="450"> <p> <a href="https://chiamzhang.github.io" target="_blank">DogEgg</a> <i class="iconfont icon-love"></i> <a href="#" target="_blank">LittePig</a> </p> <p> Powered by  <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-pen"></i> Theme  <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> </p> </div> </footer> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>




  
<script src="/js/love.js"></script>
<script src="/js/funnyTitle.js"></script>
<script src="/js/backTop.js"></script>
<script src="//cdn.jsdelivr.net/gh/bynotes/texiao/source/js/xiaoxuehua.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/wanko.model.json"},"display":{"position":"left","width":150,"height":150,"hOffset":20,"vOffset":0},"mobile":{"show":false,"scale":0.5},"react":{"opacity":0.9},"log":false});</script></body>
</html>
